package cn.edu.sdjzu.xg.eagle.controller;
import cn.edu.sdjzu.xg.eagle.entities.Club;
import cn.edu.sdjzu.xg.eagle.service.impl.ClubImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.sql.SQLException;
import java.util.List;
@RestController
@RequestMapping("clubs")
public class ClubController {

    @Autowired
    private ClubImpl clubService;

    @PostMapping
    public String addClub(@RequestBody Club club) throws SQLException {
        return clubService.addClub(club);
    }

    @DeleteMapping("/{id}")
    public String deleteClub(@PathVariable String id) throws SQLException {
        return clubService.deleteClub(id);
    }

    @PutMapping
    public String updateClub(@RequestBody Club club) throws SQLException {
        return clubService.updateClub(club);
    }

    @GetMapping("/{id}")
    public Club getClub(@PathVariable String id) throws SQLException {
        return clubService.findClubById(id);
    }

    @GetMapping
    public List<Club> getAllClubs() throws SQLException {
        return clubService.findClubs();
    }
}
